tests: Add test for including ostree.h
authorMatthew Leeds <matthew.leeds@endlessm.com>
Wed, 6 Jun 2018 21:34:01 +0000 (14:34 -0700)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 7 Jun 2018 17:28:49 +0000 (17:28 +0000)
Closes: #1615
Approved by: jlebon

Makefile-tests.am
tests/.gitignore
tests/test-include-ostree-h.c [new file with mode: 0644]

index 1bdad4c12ec0cd75bfacc7792f4de68dccb1db27..97a71d0dea9561bfe3445c7ffc6d96ab9a945a53 100644 (file)
@@ -242,7 +242,7 @@ endif
 _installed_or_uninstalled_test_programs = tests/test-varint tests/test-ot-unix-utils tests/test-bsdiff tests/test-mutable-tree \
        tests/test-keyfile-utils tests/test-ot-opt-utils tests/test-ot-tool-util \
        tests/test-gpg-verify-result tests/test-checksum tests/test-lzma tests/test-rollsum \
-       tests/test-basic-c tests/test-sysroot-c tests/test-pull-c tests/test-repo
+       tests/test-basic-c tests/test-sysroot-c tests/test-pull-c tests/test-repo tests/test-include-ostree-h
 
 if USE_AVAHI
 test_programs += tests/test-repo-finder-avahi
@@ -278,6 +278,13 @@ tests_test_bloom_SOURCES = src/libostree/ostree-bloom.c tests/test-bloom.c
 tests_test_bloom_CFLAGS = $(TESTS_CFLAGS)
 tests_test_bloom_LDADD = $(TESTS_LDADD)
 
+tests_test_include_ostree_h_SOURCES = tests/test-include-ostree-h.c
+# Don't use TESTS_CFLAGS so we test if the public header can be included by external programs
+tests_test_include_ostree_h_CFLAGS = $(AM_CFLAGS) $(OT_INTERNAL_GIO_UNIX_CFLAGS) -I$(srcdir)/src/libostree -I$(builddir)/src/libostree
+# Don't define OSTREE_COMPILATION so that we're compiling as if it's an external program
+tests_test_include_ostree_h_CPPFLAGS = $(AM_CPPFLAGS) -UOSTREE_COMPILATION
+tests_test_include_ostree_h_LDADD = $(TESTS_LDADD)
+
 if USE_AVAHI
 tests_test_repo_finder_avahi_SOURCES = src/libostree/ostree-repo-finder-avahi-parser.c tests/test-repo-finder-avahi.c
 tests_test_repo_finder_avahi_CFLAGS = $(TESTS_CFLAGS)
index d5b497488540f8dbad392244b2c7575cc9ba7aa0..8f03c0260f88abdab3af0ce526a0e83c27892ec0 100644 (file)
@@ -11,6 +11,7 @@ test-bloom
 test-bsdiff
 test-checksum
 test-gpg-verify-result
+test-include-ostree-h
 test-keyfile-utils
 test-mutable-tree
 test-ot-opt-utils
diff --git a/tests/test-include-ostree-h.c b/tests/test-include-ostree-h.c
new file mode 100644 (file)
index 0000000..af41bb3
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright © 2018 Endless Mobile, Inc.
+ *
+ * SPDX-License-Identifier: LGPL-2.0+
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *  - Matthew Leeds <matthew.leeds@endlessm.com>
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <locale.h>
+#include <ostree.h>
+
+static void
+test_include_ostree_h_compiled (void)
+{
+}
+
+/* Just ensure that we can compile with ostree.h included */
+int main (int argc, char **argv)
+{
+  setlocale (LC_ALL, "");
+  g_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/include-ostree-h/compiled", test_include_ostree_h_compiled);
+
+  return g_test_run();
+}